<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String ctx = request.getContextPath();
    request.setAttribute("ctx", ctx);
%>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="js/fileupload.js"></script>
    <script src="My97DatePicker/WdatePicker.js"></script>
    <link rel="stylesheet" href="css/img.css">
    <script>
        function toupd() {
            var formData = new FormData($("form")[0]);
            $.ajax({
                       url:"upd.do",
                       type:"post",
                       data:formData,
                       dataType:"json",
                       success:function(obj) {
                            if (obj>0){
                                alert("修改成功");
                                location="list.do";
                            }
                       },
                processData: false,
                contentType:false
                  })
        }
        $.ajax({
                   url:"getById.do",
                   type:"post",
                   data:{"aid":$("[name='aid']").val()},
                   dataType:"json",
                   success:function(obj) {
                        $("[name='tid']").val(obj.tid);
                        $("[name='title']").val(obj.title);
                        $("[name='img']").val(obj.img);
                        $("[name='content']").val(obj.content);
                        $("[name='createtime']").val(obj.createtime);
                   }
              })
    </script>
</head>
<body>
<form>
    编号:<input type="text" name="aid" value="${param.aid}"><br>
    标签:<input type="text" name="tid"><br>
    标题:<input type="text" name="title"><br>
    图片:
    <div class="photoUpLoad">
        <input type="file" class="photo" name="photo" accept="image/*"><span class="cross">+</span>
        <img src="" alt="" class="photoEcho">
    </div><br>
    内容:<input type="text" name="content"><br>
    日期:<input type="text" name="createtime" onclick="WdatePicker()">
    <input type="button" value="编辑" onclick="toupd()">
</form>
</body>
</html>
